﻿using System;
using System.Collections;

namespace mst_regex
{
    internal class EodScheduler
    {
        private readonly ArrayList _weekends = new ArrayList();

        public EodScheduler()
        {
            AddWeekend(DayOfWeek.Friday);
            AddWeekend(DayOfWeek.Saturday);
        }

        public DateTime TimeStart { get; set; }

        public void AddWeekend(DayOfWeek value)
        {
            if (!_weekends.Contains(value))
                _weekends.Add(value);
        }

        public DayOfWeek[] GetWeekends()
        {
            return (DayOfWeek[]) _weekends.ToArray(typeof (DayOfWeek));
        }

        public bool IsWeekend(DayOfWeek dow)
        {
            return _weekends.Contains(dow);
        }

        public void ClearWeekends()
        {
            _weekends.Clear();
        }

        public bool CheckTime(DateTime time)
        {
            foreach (DayOfWeek dow in GetWeekends())
            {
                if (time.DayOfWeek == dow)
                    return false;
            }

            return ((time.Hour >= TimeStart.Hour) && (time.Minute >= TimeStart.Minute));
        }
    }
}